﻿@model List<DotNet.JCore.Entity.SyncCarExitStationModel>
@using DotNet.Web;
@{
    Layout = null;
    int total = Model.Count;
    var confirm_id = "";
    var infraction_id = "";
    var btnconfirm = "";
    var btninfraction = "";
}
<div class="djcCenNum">共搜索到<span id="sys_totalcount">@total</span>条符合条件的信息</div>
<script>
    //确认稽查
    function SubmitConfrimData(id) {
        var tb_confirm_id = "#confirm" + id;
        var tb_infraction_id = "#infraction" + id;
        $(tb_confirm_id).show();
        $(tb_infraction_id).hide();
    }
    //违规登记
    function SubmitInfractionData(id) {
        var tb_confirm_id = "#confirm" + id;
        var tb_infraction_id = "#infraction" + id;
        $(tb_infraction_id).show();
        $(tb_confirm_id).hide();
    }
</script>
@if (total > 0)
{
    foreach (var item in Model)
    {
        confirm_id = "confirm" + @item.Id;
        infraction_id = "infraction" + @item.Id;
        btnconfirm = "djcCTSQr" + @item.Id;
        btninfraction = "djcCTSWg" + @item.Id;
        <div class="djcCenTab">
            @*<form id="form1" class="form-horizontal uiform" method="post"
                style="background: #f0fdf1;"
                data-modal="true"
                data-table=".uitable"
                data-error-el=".alert-danger"
                data-on-submit-success="fx.mtfSuccess"
                action="@Url.Action("Save")">*@

            @Html.AntiForgeryToken()
            @Html.MarkCreate()
            <table class="djcCTDri">
                <tr>
                    <td>车牌号</td>
                    <td>@item.BusCode</td>
                    <td>客运站</td>
                    <td>@item.OwnerStationName</td>
                </tr>
                @if (item.OutTime == null)
                {
                <tr>
                   
                        <td>出站时间</td>
                        <td style="font-weight:800;">未登记</td>
                        <td>运行时间</td>
                        <td></td>
                 </tr>

                <tr>
                    <td>出站乘客</td>
                    <td style="font-weight:800;">未登记</td>
                   
                    <td>线路</td>
                    <td>@item.LineName</td>
                </tr>

                }
                else
                {
                   <tr>
                        <td>出站时间</td>
                        <td style="font-weight:800;">@DateTimeHelper.FormatDateHasSecond(item.OutTime)</td>
                        <td>运行时间</td>
                        <td style="font-weight:800;">
                            @if (item.RunSecond > 120)
                            {<text>大于2小时</text>}
                            else
                            {<text>@item.RunSecond 分钟</text>}
                        </td>
                    
                </tr>
               
                <tr>
                    <td>出站乘客</td>
                    <td style="font-weight:800; color:red;">@item.OutNum 人</td>
                    <td>线路</td>
                    <td>@item.LineName</td>
                </tr>
                }
                <tr>
                    <td>司机姓名</td>
                    <td>@item.Driver1Name</td>
                    <td>司机电话</td>
                    <td>@item.Driver1Tel</td>
                </tr>
                <tr>
                    <td>运输企业</td>
                    <td>@item.OwnerCompName</td>
                    <td>运行状态</td>
                    <td>
    @if (item.RunStatus)
                    { <span style="color:lightgreen; font-weight:800;">正常</span> }
                    else
                    {
        <span style="color:red; font-weight:800;">异常</span>
    }
                    </td>
                </tr>
                <tr>
                    <td>稽查点</td>
                    <td>@item.PointName</td>
                    <td>备注</td>
                    <td>@item.Note</td>
                    @*<td>有效</td>
                        <td>@Html.BoolLabel(item.Enabled, item.EnabledText, item.EnabledText)</td>*@
                </tr>
            </table>
            <table class="djcCTSel">
                <tr>
                    <td><a class="djcCTSQr" onclick="SubmitConfrimData(@item.Id)">稽查确认</a><i></i></td>
                    <td><a class="djcCTSWg" onclick="SubmitInfractionData(@item.Id)">违规登记</a><i></i></td>
                </tr>
            </table>
            <!--稽查确认 class="form-horizontal uiform" method="post"
                  style="background: #f0fdf1;"
                  data-modal="true"
                  data-table=".uitable"
                  data-error-el=".alert-danger"
                  data-on-submit-success="fx.mtfSuccess"
                  action="@Url.Action("Save")"-->
            <form id="form1">
                <table id="@confirm_id" class="djcCTSQrCen">
                    <tr><td>备注</td><td><textarea id="Note" name="@nameof(item.Note)">系统正常登记</textarea></td></tr>
                    <tr><td colspan="2"><input type="button" onclick="return ConfrimData()" value="保存" class="djcCFBut" /></td></tr>
                </table>
                <input type="hidden" id="dara_id" name="dara_id" value="@item.Id" />
                <input name="@nameof(item.Id)" value="@item.Id" type="hidden" />
                <input name="@nameof(item.RunSecond)" value="@item.RunSecond" type="hidden" />
                <input name="@nameof(item.BusCode)" value="@item.BusCode" type="hidden" />
                <input name="@nameof(item.OwnerStationName)" value="@item.OwnerStationName" type="hidden" />
                <input name="@nameof(item.OutTime)" value="@item.OutTime" type="hidden" />
                <input name="@nameof(item.SaleCount)" value="@item.SaleCount" type="hidden" />
                <input name="@nameof(item.OutNum)" value="@item.OutNum" type="hidden" />
                <input name="@nameof(item.SeatCount)" value="@item.SeatCount" type="hidden" />
                <input name="@nameof(item.Enabled)" value="@item.Enabled" type="hidden" />
                <input name="@nameof(item.Driver1Name)" value="@item.Driver1Name" type="hidden" />
                <input name="@nameof(item.Driver1Tel)" value="@item.Driver1Tel" type="hidden" />
                <input name="@nameof(item.LineName)" value="@item.LineName" type="hidden" />
                <input name="@nameof(item.OwnerCompName)" value="@item.OwnerCompName" type="hidden" />
                <input name="@nameof(item.CheckStatus)" value="@item.CheckStatus" type="hidden" />
                <input name="@nameof(item.ProcessStatus)" value="@item.ProcessStatus.ToString()" type="hidden" />
                <input name="@nameof(item.OwnerStation)" value="@item.OwnerStation" type="hidden" />
            </form>
            <!--违规登记class="form-horizontal uiform" method="post"
                  style="background: #f0fdf1;"
                  data-modal="true"
                  data-table=".uitable"
                  data-error-el=".alert-danger"
                  data-on-submit-success="fx.mtfSuccess"
                  action="@Url.Action("Save")"-->
            <form id="form2">
                <table id="@infraction_id" class="djcCTSWgCen">
                    <tr>
                        <td>违规内容</td>
                        <td>
                            <select class="form-control uiselect" id="OffenceId" name="@nameof(item.OffenceId)"
                                    data-text-field="OffenceName" data-width="300"
                                    data-validate="required: true,maxlength: 4"
                                    data-validate-message="required:'请选择违规状态'">
                                @Html.EmptyOption("全部违规状态")
                                @Html.OffenceIdCategoryOption(item.OffenceId)
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>备注</td>
                        <td><textarea id="Notes" name="@nameof(item.Note)">系统违规登记</textarea></td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <input type="button" value="保存" onclick="return InfractionData()" class="djcCFBut" />
                        </td>
                    </tr>
                </table>
                <input type="hidden" id="dara_id" name="dara_id" value="@item.Id" />
                <input name="@nameof(item.Id)" value="@item.Id" type="hidden" />
                <input name="@nameof(item.RunSecond)" value="@item.RunSecond" type="hidden" />
                <input name="@nameof(item.BusCode)" value="@item.BusCode" type="hidden" />
                <input name="@nameof(item.OwnerStationName)" value="@item.OwnerStationName" type="hidden" />
                <input name="@nameof(item.OutTime)" value="@item.OutTime" type="hidden" />
                <input name="@nameof(item.SaleCount)" value="@item.SaleCount" type="hidden" />
                <input name="@nameof(item.OutNum)" value="@item.OutNum" type="hidden" />
                <input name="@nameof(item.SeatCount)" value="@item.SeatCount" type="hidden" />
                <input name="@nameof(item.Enabled)" value="@item.Enabled" type="hidden" />
                <input name="@nameof(item.Driver1Name)" value="@item.Driver1Name" type="hidden" />
                <input name="@nameof(item.Driver1Tel)" value="@item.Driver1Tel" type="hidden" />
                <input name="@nameof(item.LineName)" value="@item.LineName" type="hidden" />
                <input name="@nameof(item.OwnerCompName)" value="@item.OwnerCompName" type="hidden" />
                <input name="@nameof(item.CheckStatus)" value="@item.CheckStatus" type="hidden" />
                <input name="@nameof(item.ProcessStatus)" value="@item.ProcessStatus.ToString()" type="hidden" />
                <input name="@nameof(item.OwnerStation)" value="@item.OwnerStation" type="hidden" />
            </form>
        </div>
    }
}
else
{
    <div class="djcCenNone">如未查询到符合条件的车辆，可点击此处<a href="@Url.Action("Create", "M_ManualReg")">人工稽查</a></div>

}
<script>
    function ConfrimData() {
        var id = $("#dara_id").val();
        var note = $("#Note").val();
        $.ajax({
            type: "POST",
            url: "/M_SyncCarExitStation/Confrim",
            dataType: 'json',
            data: { ID: id, Note: note },
            success: function (data) {
                if (data.success) {
                    layer.open({
                        content: '稽查确认保存成功！'
                        , btn: ['继续登记', '返回主页']
                        , skin: 'up'
                        , yes: function (index) { window.location = '@Url.Action("Index", "M_SyncCarExitStation")'; }
                        , no: function (index) {
                            window.location = '@Url.Action("home", "M_login")';
                        }
                    });
                }
                else {
                    layer.open({
                        content: data.message
                        , btn: '我知道了'
                    });
                }
            }
        });
        return false;
    };
    function InfractionData()
    {
        var id = $("#dara_id").val();
        var OffenceId = $("#OffenceId").val().trim();
        var Offence = $("#OffenceId").find("option:selected").text();
        if (OffenceId == null || OffenceId=="" || OffenceId.length <= 0)
        {
            layer.open({ content: "请选择违规内容！", btn: "确定" });
            return false;
        }
        var note = $("#Notes").val();
        $.ajax({
            type: "POST",
            url: "/M_SyncCarExitStation/Infraction",
            dataType: 'json',
            data: { ID: id, OffenceId: OffenceId, Offence: Offence, Note: note },
            success: function (data) {
                if (data.success) {
                    layer.open({
                        content: '违规登记保存成功'
                        , btn: ['继续登记',  '返回主页']
                        , skin: 'up'
                        , yes: function (index) { window.location = '@Url.Action("Index", "M_SyncCarExitStation")'; }
                        , no: function (index) {
                            window.location = '@Url.Action("home", "M_login")';
                        }
                    });
                }
                else {
                    layer.open({
                        content: data.message
                        , btn: '我知道了'
                    });
                }
            }
        });
        return false;
    }
</script>